package com.lazydong.apiforward.clientupdate.constant;

import cn.hutool.core.io.FileUtil;

import java.io.File;
import java.nio.charset.StandardCharsets;
import java.util.List;

public class UpdateConstant {
    public static final String CURRENT_DIR = System.getProperty("user.dir");
    public static final String UPDATE_SUB_DIR = "update";
    public static final String CLIENT_DIR;
    public static final String CLIENT_UPDATE_DIR;
    public static final String DOWNLOAD_PATH = "/update/downClientExeZip";

    static {
        if (CURRENT_DIR.endsWith(UPDATE_SUB_DIR)) {
            CLIENT_UPDATE_DIR = CURRENT_DIR;
            CLIENT_DIR = FileUtil.getParent(CURRENT_DIR, 1);
        } else {
            CLIENT_UPDATE_DIR = CURRENT_DIR + File.separator + UPDATE_SUB_DIR;
            CLIENT_DIR = CURRENT_DIR;
        }
    }
    public static final String CLIENT_ZIP_PATH = CLIENT_UPDATE_DIR + File.separator + "ApiForwardClient.zip";
    public static final String CLIENT_EXE_PATH = CLIENT_DIR + File.separator + "ApiForwardClient.exe";
    public static final String CLIENT_PID_PATH = CLIENT_DIR + File.separator + "ApiForwardClient.pid";
    public static final String SERVER_IP_ADDRESS = CLIENT_DIR + File.separator + "服务器地址.txt";
    public static final String UPDATE_LOCK_SUFFIX = "update.lock";
    public static final String UPDATE_SUCCESS_FLAG = CLIENT_UPDATE_DIR + File.separator + "update_success.lock";
}